<cfcomponent output="false">

	<cffunction name="read" output="false" access="public" returntype="src.com.DAC.confluence.PersonVO">
		<cfargument name="id" required="true">
		<cfset var qRead="">
		<cfset var obj="">

		<cfquery name="qRead" datasource="stitch">
			select 	person_id, person_firstname, person_lastname
			from tbl_person
			where person_id = <cfqueryparam cfsqltype="CF_SQL_BIGINT" value="#arguments.id#" />
		</cfquery>

		<cfscript>
			obj = createObject("component", "src.com.DAC.confluence.PersonVO").init();
			obj.setperson_id(qRead.person_id);
			obj.setperson_firstname(qRead.person_firstname);
			obj.setperson_lastname(qRead.person_lastname);
			return obj;
		</cfscript>
	</cffunction>



	<cffunction name="create" output="false" access="public">
		<cfargument name="bean" required="true" type="src.com.DAC.confluence.PersonVO">
		<cfset var qCreate="">

		<cfset var qGetId="">

		<cfset var local1=arguments.bean.getperson_firstname()>
		<cfset var local2=arguments.bean.getperson_lastname()>

		<cftransaction isolation="read_committed">
			<cfquery name="qCreate" datasource="stitch">
				insert into tbl_person(person_firstname, person_lastname)
				values (
					<cfqueryparam value="#local1#" cfsqltype="CF_SQL_VARCHAR" />,
					<cfqueryparam value="#local2#" cfsqltype="CF_SQL_VARCHAR" />
				)
			</cfquery>

			<!--- If your server has a better way to get the ID that is more reliable, use that instead --->
			<cfquery name="qGetID" datasource="stitch">
				select person_id
				from tbl_person
				where person_firstname = <cfqueryparam value="#local1#" cfsqltype="CF_SQL_VARCHAR" />
				  and person_lastname = <cfqueryparam value="#local2#" cfsqltype="CF_SQL_VARCHAR" />
				order by person_id desc
			</cfquery>
		</cftransaction>

		<cfscript>
			arguments.bean.setperson_id(qGetID.person_id);
		</cfscript>
		<cfreturn arguments.bean />
	</cffunction>



	<cffunction name="update" output="false" access="public">
		<cfargument name="bean" required="true" type="src.com.DAC.confluence.PersonVO">
		<cfset var qUpdate="">

		<cfquery name="qUpdate" datasource="stitch" result="status">
			update tbl_person
			set person_firstname = <cfqueryparam value="#arguments.bean.getperson_firstname()#" cfsqltype="CF_SQL_VARCHAR" />,
				person_lastname = <cfqueryparam value="#arguments.bean.getperson_lastname()#" cfsqltype="CF_SQL_VARCHAR" />
			where person_id = <cfqueryparam value="#arguments.bean.getperson_id()#" cfsqltype="CF_SQL_BIGINT">
		</cfquery>
		<cfreturn arguments.bean />
	</cffunction>



	<cffunction name="delete" output="false" access="public" returntype="void">
		<cfargument name="bean" required="true" type="src.com.DAC.confluence.PersonVO">
		<cfset var qDelete="">

		<cfquery name="qDelete" datasource="stitch" result="status">
			delete
			from tbl_person
			where person_id = <cfqueryparam cfsqltype="CF_SQL_BIGINT" value="#arguments.bean.getperson_id()#" />
		</cfquery>

	</cffunction>


</cfcomponent>